import api from "@/api/common"
const site = {
    state: {
        site_name: "",
        site_beian:"",
        site_logo:"",
        site_hotline:"",
        header_nav:{},
        footer_nav:{},
        footer_item:{}
    },
    
    mutations:{
        SET_SITE_NAME: (state, site_name) => {
            state.site_name = site_name;
        },
        SET_SITE_BEIAN:(state, site_beian) => {
            state.site_beian = site_beian;
        },
        SET_SITE_LOGO:(state, site_logo) => {
            state.site_logo = site_logo;
        },
        SET_SITE_HOTLINE:(state, site_hotline) => {
            state.site_hotline = site_hotline;
        },
        SET_HEADER_NAV:(state, header_nav) => {
            state.header_nav = header_nav;
        },
        SET_FOOTER_NAV:(state, footer_nav) => {
            state.footer_nav = footer_nav;
        },
        SET_FOOTER_ITEM:(state, footer_item) => {
            state.footer_item = footer_item;
        },
    },
    actions: {
    // 获取站点信息
    GetSiteInfo({ commit, state }) {
        return new Promise((resolve, reject) => {
            let input={
                apikey:"123456789"
            }
            api.InitSiteInfo(input)
            .then((res) => {
              const model = res.data;
              commit("SET_SITE_NAME", model.site.site_name);
              commit("SET_SITE_BEIAN", model.site.site_beian);
              commit("SET_SITE_LOGO", model.site.site_logo);
              commit("SET_SITE_HOTLINE", model.site.site_hotline);
              commit("SET_HEADER_NAV", model.site.header_nav);
              commit("SET_FOOTER_NAV", model.site.footer_nav);
              commit("SET_FOOTER_ITEM", model.site.footer_item);
              resolve(res);
            })
            .catch((error) => {
              reject(error);
            });
        });
      },
    }
}


export default site;